package com.qf.controller;

import com.qf.entity.TlPerson;
import com.qf.service.PersonService;
import com.qf.utils.ResultMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/person")
public class PersonController {
    @Autowired
    PersonService personService;

    //查询乘车人信息
    @GetMapping("/findAllPerson")
    public ResultMsg findAllPerson(HttpServletRequest request){
        return personService.findAllPerson(request);
    }
    //新增和修改
    @PostMapping("/modify")
    public ResultMsg modify(@RequestBody TlPerson tlPerson,HttpServletRequest request){
        return personService.modify(tlPerson,request);
    }
    //乘车人提交按钮
    @PostMapping("/submit")
    public ResultMsg submit(@RequestBody TlPerson[] tlPeople){
        return ResultMsg.SUCCESS(tlPeople);
    }

    //添加乘车人
    @GetMapping("/insert")
    public ResultMsg insert(Integer userId,String personName,String personCard,String personTel,Integer personFlag){
        return personService.insert(userId,personName,personCard,personTel,personFlag);
    }
}
